package com.x.erp.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.CarAgeDao;
import com.x.erp.manage.CarAgeManage;
import com.x.erp.model.CarAge;
import com.x.erp.rpc.CarAgeRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;

/**
 * 车龄服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.CarAgeRpcService", timeout = 60000)
public class CarAgeService extends BaseService implements CarAgeRpcService {

	@Autowired
	private CarAgeDao carAgeDao;// 车龄信息DAO

	@Autowired
	private CarAgeManage carAgeManage;// 车龄信息Manage

	/**
	 * 查询车龄列表
	 * @param carAge
	 * @return
	 */
	@Override
	public List<CarAge> selectCarAgeList(CarAge carAge) {
		try {
			return carAgeDao.selectCarAgeList(carAge);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 新增车龄信息
	 * @param carAge
	 * @return
	 */
	@Override
	public CarAge insertCarAge(CarAge carAge) {
		try {
			return this.insert(carAge);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 修改车龄信息
	 * @param carAge
	 * @return
	 */
	@Override
	public int updateCarAge(CarAge carAge) {
		try {
			return this.updateCarAge(carAge);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 修改车龄信息任务
	 * @param carAge
	 * @return
	 */
	@Override
	public int updateCarAgeTask(CarAge carAge) {
		try {
			return carAgeManage.updateCarAgeTask(carAge);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

}
